@extends("web.layout.common_login")
@section("title")
    登录
@endsection
@section('style')
@endsection
@section('content')
    <div class="main">
        <div class="login">
            <div class="login_box">
                <div class="login_left_box fl">

                </div>
                <div class="login_right_box fl">
                    <div class="title"><h2>登录</h2></div>
                    <div id="normal">
                        <form action="{{ route('web.login',['account'=>request('domain')]) }}" method="post" id="normal_form">
                            @csrf
                            <div class="mb-3">
                                <input type="hidden" name="type" value="1">
                                <input type="text" name="username" class="form-control"  placeholder="请输入用户名" required>
                            </div>
                            <div class="mb-3">
                                <input type="password" name="password" class="form-control"  placeholder="请输入密码" required>
                            </div>
                        </form>
                    </div>
                    <div id="message" style="display: none">
                        <form action="{{ route('web.login',['account'=>request('domain')]) }}" method="post" id="message_form">
                            @csrf
                            <div class="mb-3">
                                <input type="hidden" name="type" value="2">
                                <input type="text" name="mobile" class="form-control"  placeholder="请输入手机号">
                            </div>
                            <div class="input-group mb-3">
                                <input type="number" name="code" class="form-control" readonly placeholder="请输入验证码">
                                <button class="btn btn-outline-secondary message" id="send" type="button">发送验证码</button>
                            </div>
                        </form>
                    </div>

                    <div class="col-sm-6 fl remember mb-3">
                        <input type="checkbox" class="form-check-input" id="exampleCheck1">
                        <label class="form-check-label" for="exampleCheck1">记住我</label>
                    </div>
                    <div class="col-sm-6 fr" style="text-align: right;">
                        <a id="check">短信验证登录</a>
                    </div>
                    <div class="submit">
                        <button type="button" id="submit">登录</button>
                    </div>
                    <div class="forget">
                        <a>已有帐号，忘记密码？</a>
                    </div>
                    <script>

                    </script>
                    <div>
                        <div class="leftline fl"></div>
                        <div class="text-muted fl" style="width: 33%;text-align: center;font-size: 14px;">其他方式登录</div>
                        <div class="leftline fl"></div>
                    </div>
                    <div class="clearfix"></div>
                    <div class="other">
                        <div class="item">
                            <a href="{{route('web.qrcode',['account'=>request('domain')])}}"><img src="/images/icon_wechat.png" /></a>
                        </div>
                    </div>
                </div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>

@endsection
@section('script')
    <script>
        $("#check").click(function(){
            if($("#normal").is(":hidden")){
                $("#normal").show();
                $("#message").hide();
                $(this).text("短信验证登录");
            }else{
                $("#normal").hide();
                $("#message").show();
                $(this).text("用户名密码登录");
            }

        });
        $("#submit").click(function(){
            var that;
            if($("#normal").is(":hidden")){
                that = $('#message_form')
            }else{
                that = $('#normal_form');
            }
            var data = that.serialize();
            var action = that.attr('action');
            $.post(action,data,function(res){
                var icon = 5;
                if(res.error == 0){
                    icon = 6;
                }
                layer.msg(res.msg, {icon: icon},function(){
                    if(res.error == 0){
                        window.location.href = '{{ route('index') }}';
                    }
                });
            })
        });
        $("#send").click(function(){
            $("input[name='code']").removeAttr("readonly");
            $(this).text("已发送")
        })
    </script>
@endsection


